package cpi.utils;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*
工具配置类 springboot继承swagger
swagger就是前后端分离开发时生成服务器端API文档的
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket initDocket(Environment e){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("cpi系统")
                .description("cpi第一组API文档")
                .contact(new Contact("张三",
                        "https://baidu.com","xxx@qq.com"))
                .version("1.0").build();
    }
}
